package com.tidemark;

/**
 * Stock, contains stock-code and stock-name
 * stock is sortable by stock-code 
 *
 */
public class Stock implements Comparable<Stock>{
	private String m_code;    //e.g. 600050 for 中国联通
	private String m_name;    //e.g. 中国联通 or China Unicom
	private String m_symbol;  //e.g. ZGLT for 中国联通
	private String m_comments;//e.g. 牛 or 熊
	private int suggestion = 0;      //0 for no suggestion, 1 for buy, -1 for sale
	
	public int getSuggestion() {
		return suggestion;
	}

	public void setSuggestion(int suggestion) {
		this.suggestion = suggestion;
	}

	public String getComments() {
		return m_comments;
	}

	public void setComments(String comments) {
		this.m_comments = comments;
	}

	public Stock() {
		this("-1", "");
	}
	
	public Stock(String code, String name) {
		m_code = code;
		m_name = name;
	}
	
	public Stock(String code, String name, String comments, int suggestion) {
		m_code = code;
		m_name = name;
		m_comments = comments;
		this.suggestion = suggestion;
	}
	
	@Override
	public int compareTo(Stock arg0) {
		int code0 = Integer.parseInt(arg0.getCode());
		int code1 = Integer.parseInt(this.getCode());
		
			if(code0 == code1){
				return 0;
			}else	if(code1 < code0){
				return -1;
			}else{
				return 1;
			}
	}

	public String getCode() {
		return m_code;
	}

	public void setCode(String code) {
		this.m_code = code;
	}

	public String getName() {
		return m_name;
	}

	public void setName(String name) {
		this.m_name = name;
	}
	
	public String toString() {
		return m_code + " " + m_name + " " + m_comments;
	}
}